package com.jiangxiaofei.citycloud.adapter;

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jiangxiaofei.citycloud.R;
import com.jiangxiaofei.citycloud.bean.FreshFruitCassifyBean;

import java.util.List;


/**
 * @author: JiangXFei
 * @date: 2017/11/23 0023
 * @content:
 */

public class FreshCassifyAdapter extends BaseQuickAdapter<FreshFruitCassifyBean, BaseViewHolder> {
    public FreshCassifyAdapter(int layoutResId, @Nullable List<FreshFruitCassifyBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, FreshFruitCassifyBean item) {
        TextView tv = helper.getView(R.id.tv_cassify_type);
        View v = helper.getView(R.id.view_blue);
        tv.setText(item.getName());
        if (item.isChecked()) {
            tv.setBackgroundColor(Color.parseColor("#ffffff"));
            tv.setTextColor(Color.parseColor("#66c9ff"));
            v.setVisibility(View.VISIBLE);
        } else {
            tv.setTextColor(Color.parseColor("#808080"));
            tv.setBackgroundColor(Color.parseColor("#00000000"));
            v.setVisibility(View.GONE);
        }
    }


    public static class FreshCassifyItemAdapter extends BaseQuickAdapter<FreshFruitCassifyBean, BaseViewHolder> {

        public FreshCassifyItemAdapter(int layoutResId, @Nullable List<FreshFruitCassifyBean> data) {
            super(layoutResId, data);
        }

        @Override
        protected void convert(BaseViewHolder helper, FreshFruitCassifyBean item) {
            ImageView img = helper.getView(R.id.img_cassfity_menu);
            Glide.with(mContext).load(item.getImg()).into(img);
            helper.setText(R.id.tv_cassify_menu, item.getName());
        }
    }
}
